
# 数据导入
from keras.utils import np_utils
from tensorflow.keras.datasets import mnist

(x_train,y_train),(x_test,y_test) = mnist.load_data(path=r"F:\dataset\MNIST\keras\datasets\mnist.npz")

def getTrainData():
    global x_train,y_train
    x_train = x_train.reshape(x_train.shape[0], -1) / 255.0
    y_train = np_utils.to_categorical(y_train, num_classes=10)
    return x_train,y_train

def getTestData():
    global x_test, y_test
    x_test = x_test.reshape(x_test.shape[0],-1) / 255.0
    y_test = np_utils.to_categorical(y_test,num_classes=10)
    return x_test, y_test